package com.shuang.service.impl;

import com.shuang.mapper.ClazzMapper;
import com.shuang.mapper.EmpMapper;
import com.shuang.mapper.StudentMapper;
import com.shuang.pojo.ClazzStudentObtion;
import com.shuang.pojo.JobOption;
import com.shuang.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private EmpMapper empMapper;

    @Autowired
    private ClazzMapper clazzMapper;

    @Autowired
    private StudentMapper studentMapper;

    /*统计各职位员工人数*/
    @Override
    public JobOption getEmpJobData() {
        List<Map<String, Object>> empJobDataList =  empMapper.getEmpJobData();
        List<Object> jobList = empJobDataList.stream().map(empJobData -> empJobData.get("pos")).toList();
        List<Object> dataList = empJobDataList.stream().map(empJobData -> empJobData.get("total")).toList();
        return new JobOption(jobList, dataList);
    }

//    统计员工性别人数
    @Override
    public List<Map<String, Object>> getEmpGenderData() {
        return empMapper.getEmpGenderData();
    }

    /*统计班级学员人数*/
    @Override
    public ClazzStudentObtion getClazzStudentData() {
        List< Map<String, Object> > clazzStudentDataList = clazzMapper.getClazzStudentData();

        List<Object> clazzName = clazzStudentDataList.stream().map(clazzStudentData -> clazzStudentData.get("clazzName")).toList();
        List<Object> num = clazzStudentDataList.stream().map(clazzStudentData -> clazzStudentData.get("num")).toList();

        return new ClazzStudentObtion(clazzName, num);
    }

    /*统计学员学历信息*/
    @Override
    public List<Map<String, Object>> getStudentDegreeData() {

        return studentMapper.getStudentDegreeData();
    }
}
